package com.xique.blelock.Utils;

import com.xique.blelock.model.FingerInfo;
import com.xique.blelock.model.LockAllinfo;
import com.xique.blelock.model.OpenLockMode;
import com.xique.blelock.model.Operationinfo;
import com.xique.blelock.model.UserOfLockinfo;

import java.util.List;

/**
 * Created by Administrator on 2018/12/31.
 */

public class CommUtil {

    public static List<Operationinfo> searchName(List<Operationinfo> operationinfoList, LockAllinfo lockAllinfo){

        for(Operationinfo operationinfo: operationinfoList){
            if(operationinfo.getMode() == OpenLockMode.BLE){
                    for(UserOfLockinfo userOfLockinfo: lockAllinfo.getLockBandUserList()){
                        if(userOfLockinfo.getOrder() == operationinfo.getOrder()){
                            operationinfo.setNickName(userOfLockinfo.getNickname());
                        }
                    }
            }
            else if(operationinfo.getMode() == OpenLockMode.FINGER){
                for(FingerInfo fingerInfo: lockAllinfo.getLockFpList()){
                    if(operationinfo.getOrder() == fingerInfo.getOrder()){
                        operationinfo.setNickName(fingerInfo.getNickname());
                    }
                }
            }
        }

        return null;
    }
}
